<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2024/3/5
 * Time: 17:29
 */

namespace app\api\model;

class Xun extends Base
{
    public $hidden = ['xun_user_id'];

    /**
     * 插入数据
     * @param $insert
     * @return int|string
     */
    static function insertData($insert = []){
        return self::insertGetId($insert);
    }

    /**
     * 多条查询
     * @param $where
     * @return bool|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    static function selectData($where = [], $page = 1){
        return self::where($where)->page($page, self::$limit)->order('xun_time desc')->select();
    }

    /**
     * 统计数量
     * @param $where
     * @return int|string
     * @throws \think\Exception
     */
    static function countData($where = []){
        return self::where($where)->count();
    }

    /**
     * 单条查询
     * @param $where
     * @return array|bool|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    static function findData($where = []){
        return self::where($where)->find();
    }
}